//ST表-质量检测
#include <iostream>
using namespace std;
int n, m;
const int N = 1e5 + 10;
int f[N][25];
int a[N];
int lg[N];

void init()
{
    lg[0] = -1;
    for(int i = 1; i <= n; i++)
    {
        lg[i] = lg[i / 2] + 1;
        f[i][0] = a[i];
    }

    for(int j = 1; (1 << j) <= n; j++)
        for(int i = 1; i + (1 << j) - 1 <= n; i++)
            f[i][j] = min(f[i][j-1], f[i + (1 << (j - 1))][j-1]);
}

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> a[i];   
    init();
    int k = lg[m];
    for(int i = 1; i + m - 1 <= n; i++)
        cout << min(f[i][k], f[i + m - (1 << k)][k]) << endl;
    return 0;
}
